﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LeoK.Common;
using LeoK.Common.Converter;

namespace LeoK.TM.Entity
{
    class TM_Task : EntityBase
    {
        private int _id;
        private DateTime _startTime;
        private DateTime _endTime;

        [EBAttribute(IsReadOnly = true)]
        [Display(Name = "ID")]
        public int ID
        {
            get { return _id; }
            set
            {
                _id = value;
                OnPropertyChanged();
            }
        }

        [Display(Name = "任务名称")]
        public string Name { get; set; }

        [EBAttribute(AllowFilter = true)]
        [Display(Name = "所属项目")]
        public int SlnID { get; set; }

        [EBAttribute(IsReadOnly = true, DataConverter = typeof(MinutesToStringConverter))]
        [Display(Name = "耗时")]
        public int TimeSpend { get; set; }

        [EBAttribute(DataConverter = typeof(MinutesToStringConverter))]
        [Display(Name = "计划耗时")]
        public int PlanTimeSpend { get; set; }

        [EBAttribute(AllowFilter = true)]
        [Display(Name = "分级")]
        public TaskLevel Level { get; set; }

        [EBAttribute(IsReadOnly = true)]
        [Display(Name = "创建时间")]
        public DateTime StartTime
        {
            get { return _startTime; }
            set
            {
                _startTime = value; 
                OnPropertyChanged();
            }
        }

        [EBAttribute(IsReadOnly = true)]
        [Display(Name = "完成时间")]
        public DateTime EndTime
        {
            get { return _endTime; }
            set
            {
                _endTime = value;
                OnPropertyChanged();
            }
        }

        [Display(Name = "备注")]
        public string Note { get; set; }

        [EBAttribute(AllowFilter = true)]
        [Display(Name = "完成")]
        public bool IsFinish { get; set; }

        public TM_Task()
        {
            Level = TaskLevel.未分级;
            Name = "新建任务";
            StartTime = DateTime.Now;
            EndTime = DateTime.Now;
        }
    }

    public enum TaskLevel
    {
        未分级 = -1,
        E = 0,
        D = 1,
        C = 2,
        B = 3,
        A = 4,
        S = 5

    }

}
